<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<!DOCTYPE HTML>
<html ng-app>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
    <title>${title}</title>
    <%@ include file="/WEB-INF/jsp/commons/meta.jsp" %>
    <link href="${ctx}/resources/new/style.css" type="text/css" rel="stylesheet"/>
    <style>
        body, html {
            height: 100%;
            width: 100%;
            padding: 0;
        }
    </style>
</head>
<body>
<%@ include file="/WEB-INF/jsp/commons/header.jsp" %>

<div id="wrap">
    <div class="container" id="content">
        <div class="accordion">
            <%--<div class="accordion-group">--%>
            <div>
                <div class="accordion-heading">
			<span class="accordion-toggle collapsed" data-toggle="collapse" href="#collapse1">
				<i class="icon-white icon-folder-open"></i>
				 ${group.name}
			</span>
                </div>
                <div class="accordion-body in collapse" id="collapse1" style="height: auto;">
                    <div class="accordion-inner ">
                        <dl>
                            <dd title="回到首页">
                                <i class="icon-white icon-home"></i>
                                <a href="${ctx}/main.html">回到首页</a>
                            </dd>
                            <c:forEach items="${resourcesList}" var="resources">
                                <dd title="${resources.memo}">
                                    <i class="icon-white ${resources.icon}"></i>
                                    <a href="${ctx}${resources.url}" target="content_iframe"
                                       name="nav-link">${resources.name}</a>
                                </dd>
                            </c:forEach>
                        </dl>
                    </div>
                </div>
            </div>
        </div>

        <div class="iframe_box">
            <ul class="nav nav-tabs">
            </ul>
            <div class="content_iframe">
            </div>
        </div>

    </div>
</div>

<div class="modal fade hide" id="myModal_msg">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>
        <h5>
            <i class="icon-comment"></i>
            消息提示
        </h5>
    </div>
    <div class="modal-body">
        <p class="modal_msg">对话框内容</p>
    </div>
    <div class="modal-footer">
        <a href="#" data-dismiss="modal" class="btn btn-small btn-primary">确 认</a>
    </div>
</div>
<div class="modal fade hide" id="noticeMsg">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>
        <h5>
            <i class="icon-comment"></i>
            系统消息
        </h5>
    </div>
    <div class="modal-body">
        <p id="modal_msg">对话框内容</p>
    </div>
    <div class="modal-footer">
        <a href="#" data-dismiss="modal" class="btn btn-small btn-primary">确 认</a>
    </div>
</div>
<%@ include file="/WEB-INF/jsp/commons/footer.jsp" %>
<script type="text/javascript">
    $(function () {
        var ContentIframe = {
            content: $(".content_iframe"),
            tabs: $(".nav.nav-tabs"),
            frames: {},
            tags: {},
            hideFrame: function () {
                var _self = this;
                for (var u in _self.frames) {
                    var i = _self.frames[u];
                    i.hide();
                }
                for (var t in _self.tags) {
                    var a = _self.tags[t];
                    a.removeClass("active");
                }
            },
            push: function (url, tagName) {
                var _self = this;
                _self.hideFrame();
                var frame = _self.frames[url];
                if (!frame) {
                    var frame = $("<iframe />");
                    frame.attr("src", url);
                    frame.attr("id", url);
                    frame.attr('frameborder', 0);
                    frame.attr("height", "100%");

                    var frameHeight = $(".content_iframe").height();
                    frame.load(function () {
                        $(this).css({
                            height: frameHeight
                        });
                        var logPage = $(this).contents().find("body#NMOS_LOGIN_PAGE");
                        if (logPage.length > 0) {
                            location.href = window.basePath + "/login.html";
                        }
                    });
                    _self.content.append(frame);
                    _self.frames[url] = frame;
                    var tab = $('<li><a>' + tagName + '</a></li>');

                    tab.click(function () {
                        _self.hideFrame();
                        frame.fadeIn();
                        $(this).addClass("active");
                    });
                    tab.addClass("active");
                    _self.tabs.append(tab);
                    _self.tags[url] = tab;
                } else {
                    var tab = _self.tags[url];
                    tab.addClass("active");
                    if (url.indexOf("?") > -1) {
                        url += "&_" + new Date().getTime();
                    } else {
                        url += "?_" + new Date().getTime();
                    }
                    frame.attr("src", url);
                    frame.fadeIn();
                }
            },
            init: function () {
                var _self = this;
                $("a[name=nav-link]").click(function () {
                    var url = $(this).attr("href");
                    var tagName = $(this).html();
                    _self.push(url, tagName);
                    return false;
                });
                $("a[name=nav-link]")[0].click();
            }
        }
        ContentIframe.init();


    });
</script>
</body>
</html>